package com.openbravo.pos.config;

import com.openbravo.data.user.DirtyManager;
import com.openbravo.pos.forms.AppLocal;
import com.openbravo.pos.util.StringParser;

import java.awt.Component;

import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.GroupLayout.ParallelGroup;
import javax.swing.GroupLayout.SequentialGroup;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JPanel;
import javax.swing.LayoutStyle;
import javax.swing.LayoutStyle.ComponentPlacement;

public class ParametersPrinter extends JPanel
  implements ParametersConfig
{
  private String othersizename = "standard";
  private JComboBox jPrinters;
  private JCheckBox jReceiptPrinter;

  public ParametersPrinter(String[] paramArrayOfString)
  {
    initComponents();
    this.jPrinters.addItem("(Default)");
    this.jPrinters.addItem("(Show dialog)");
    for (String str : paramArrayOfString)
      this.jPrinters.addItem(str);
  }

  public Component getComponent()
  {
    return this;
  }

  public void addDirtyManager(DirtyManager paramDirtyManager)
  {
    this.jPrinters.addActionListener(paramDirtyManager);
    this.jReceiptPrinter.addActionListener(paramDirtyManager);
  }

  public void setParameters(StringParser paramStringParser)
  {
    this.jPrinters.setSelectedItem(paramStringParser.nextToken(','));
    String str = paramStringParser.nextToken(',');
    this.jReceiptPrinter.setSelected("receipt".equals(str));
    this.othersizename = ("receipt".equals(str) ? "standard" : str);
  }

  public String getParameters()
  {
    return comboValue(this.jPrinters.getSelectedItem()) + "," + boolValue(this.jReceiptPrinter.isSelected());
  }

  private static String comboValue(Object paramObject)
  {
    return paramObject == null ? "" : paramObject.toString();
  }

  private String boolValue(boolean paramBoolean)
  {
    return paramBoolean ? "receipt" : this.othersizename;
  }

  private void initComponents()
  {
    this.jPrinters = new JComboBox();
    this.jReceiptPrinter = new JCheckBox();
    this.jReceiptPrinter.setSelected(true);
    this.jReceiptPrinter.setText(AppLocal.getIntString("label.receiptprinter"));
    GroupLayout localGroupLayout = new GroupLayout(this);
    setLayout(localGroupLayout);
    localGroupLayout.setHorizontalGroup(localGroupLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addGap(0, 430, 32767).addGroup(localGroupLayout.createSequentialGroup().addContainerGap().addComponent(this.jPrinters, -2, 165, -2).addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED).addComponent(this.jReceiptPrinter).addContainerGap(129, 32767)));
    localGroupLayout.setVerticalGroup(localGroupLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addGap(0, 61, 32767).addGroup(localGroupLayout.createSequentialGroup().addGroup(localGroupLayout.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(this.jPrinters, -2, -1, -2).addComponent(this.jReceiptPrinter)).addContainerGap(37, 32767)));
  }
}

/* Location:           D:\PowerFulPOS-2.30.2\openbravopos.jar
 * Qualified Name:     com.openbravo.pos.config.ParametersPrinter
 * JD-Core Version:    0.6.0
 */